import rxAjax from '@/assets/ajax.js';

//表单权限配置 api接口
export const LoginApi = {};

//获取是否加密
LoginApi.getParamsEncrypt = () => rxAjax.get(
    '/api-system/system/core/public/getParamsEncrypt'
)

LoginApi.getMultiLinguals = () => rxAjax.get(
    '/api-system/system/core/sysMultiLingual/getMultiLinguals'
)
LoginApi.getLoginConfig = (hostName) => rxAjax.get(
    '/api-system//system/core/public/getLoginConfig?hostName='+hostName
)

LoginApi.login = (parameter) => {
    return rxAjax.postForm(
    '/api-uaa/oauth/user/token',
    parameter,{token:false}
)}
LoginApi.currentUser=function() {
    let timestamp=(new Date()).getTime();
    let url= "/api-user/user/org/osUser/current?dt="+timestamp;
    return rxAjax.get(url).then (res => {
        return res
    });
}
LoginApi.updatePassword=function(params) {
    let url= '/api-user/user/org/osUser/updatePassword';
    return rxAjax.postForm(url,params).then (res => {
        return res
    });
}

//根据获取第三方平台授权地址，参数tenantId,loginType,redirectUrl, state
LoginApi.getAuthUrl=function(params) {
    var url= "/api-uaa/oauth/user/authUrl?tenantId="+params.tenantId+"&loginType="+params.loginType+"&redirectUrl="+params.redirectUrl+"&state="+params.state+"&paramType="+params.paramType;
    return rxAjax.get(url,{needToken:false}).then (res => {
        return res
    });
}

//绑定第三方平台，参数code,tenantId,loginType
LoginApi.platformBind=function(params) {
    var url= "/api-uaa/oauth/user/bind";
    return rxAjax.postForm(url,params).then (res => {
        return res
    });
}
//根据code自动登陆,参数code,tenantId,loginType
LoginApi.platformAutoLogin=function(params) {
    var url= "/api-uaa/oauth/user/autoLogin";
    return rxAjax.postForm(url,params).then (res => {
        return res
    });
}

//根据code自动登陆,参数code,tenantId,loginType
LoginApi.getDdCorpId=function(params) {
    var url= "/api-user/user/org/osPlatformIntegrate/getDdCorpId";
    return rxAjax.postForm(url,params).then (res => {
        return res
    });
}
LoginApi.getBpmInstEncrypt = function (instId){
    let url = "/api-bpm/bpm/core/bpmInst/getBpmInstEncrypt"
    return rxAjax.postForm(url,{instId:instId},{needToken:false});
}
export default LoginApi
